package de.sabram.upb.specs.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import de.sabram.upb.specs.gla.AuxiliaryScannerName;
import de.sabram.upb.specs.gla.File;
import de.sabram.upb.specs.gla.GlaPackage;
import de.sabram.upb.specs.gla.Pattern;
import de.sabram.upb.specs.gla.Specification;
import de.sabram.upb.specs.gla.TokenName;
import de.sabram.upb.specs.gla.TokenProcessorName;
import de.sabram.upb.specs.services.GlaGrammarAccess;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;

@SuppressWarnings("all")
public class GlaSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private GlaGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == GlaPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case GlaPackage.AUXILIARY_SCANNER_NAME:
				if(context == grammarAccess.getAuxiliaryScannerNameRule()) {
					sequence_AuxiliaryScannerName(context, (AuxiliaryScannerName) semanticObject); 
					return; 
				}
				else break;
			case GlaPackage.FILE:
				if(context == grammarAccess.getFileRule()) {
					sequence_File(context, (File) semanticObject); 
					return; 
				}
				else break;
			case GlaPackage.PATTERN:
				if(context == grammarAccess.getCannedExpressionRule()) {
					sequence_CannedExpression(context, (Pattern) semanticObject); 
					return; 
				}
				else if(context == grammarAccess.getPatternRule()) {
					sequence_CannedExpression_Pattern_RegularExpression(context, (Pattern) semanticObject); 
					return; 
				}
				else if(context == grammarAccess.getRegularExpressionRule()) {
					sequence_RegularExpression(context, (Pattern) semanticObject); 
					return; 
				}
				else break;
			case GlaPackage.SPECIFICATION:
				if(context == grammarAccess.getSpecificationRule()) {
					sequence_Specification(context, (Specification) semanticObject); 
					return; 
				}
				else break;
			case GlaPackage.TOKEN_NAME:
				if(context == grammarAccess.getSpecificationRule()) {
					sequence_Specification_TokenName(context, (TokenName) semanticObject); 
					return; 
				}
				else if(context == grammarAccess.getTokenNameRule()) {
					sequence_TokenName(context, (TokenName) semanticObject); 
					return; 
				}
				else break;
			case GlaPackage.TOKEN_PROCESSOR_NAME:
				if(context == grammarAccess.getTokenProcessorNameRule()) {
					sequence_TokenProcessorName(context, (TokenProcessorName) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (
	 *         value='auxEOF' | 
	 *         value='coordAdjust' | 
	 *         value='auxNewLine' | 
	 *         value='auxTab' | 
	 *         value='auxEOL' | 
	 *         value='auxPascalString' | 
	 *         value='auxPascalComment' | 
	 *         value='auxNoEOL' | 
	 *         value='auxCString' | 
	 *         value='auxCChar' | 
	 *         value='auxCComment' | 
	 *         value='auxM2String' | 
	 *         value='auxM3Comment' | 
	 *         value='Ctext'
	 *     )
	 */
	protected void sequence_AuxiliaryScannerName(EObject context, AuxiliaryScannerName semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         value='ADA_COMMENT' | 
	 *         value='ADA_IDENTIFIER' | 
	 *         value='AWK_COMMENT' | 
	 *         value='C_COMMENT' | 
	 *         value='C_CHAR_CONSTANT' | 
	 *         value='C_FLOAT' | 
	 *         value='C_IDENTIFIER' | 
	 *         value='C_INTEGER' | 
	 *         value='C_INT_DENOTATION' | 
	 *         value='C_STRING_LIT' | 
	 *         value='MODULA_INTEGER' | 
	 *         value='MODULA2_COMMENT' | 
	 *         value='MODULA3_COMMENT' | 
	 *         value='MODULA2_CHARINT' | 
	 *         value='MODULA2_INTEGER' | 
	 *         value='MODULA2_LITERALDQ' | 
	 *         value='MODULA2_LITERALSQ' | 
	 *         value='PASCAL_COMMENT' | 
	 *         value='PASCAL_IDENTIFIER' | 
	 *         value='PASCAL_INTEGER' | 
	 *         value='PASCAL_REAL' | 
	 *         value='PASCAL_STRING' | 
	 *         value='SPACES' | 
	 *         value='TAB' | 
	 *         value='NEW_LINE'
	 *     )
	 */
	protected void sequence_CannedExpression(EObject context, Pattern semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         value='ADA_COMMENT' | 
	 *         value='ADA_IDENTIFIER' | 
	 *         value='AWK_COMMENT' | 
	 *         value='C_COMMENT' | 
	 *         value='C_CHAR_CONSTANT' | 
	 *         value='C_FLOAT' | 
	 *         value='C_IDENTIFIER' | 
	 *         value='C_INTEGER' | 
	 *         value='C_INT_DENOTATION' | 
	 *         value='C_STRING_LIT' | 
	 *         value='MODULA_INTEGER' | 
	 *         value='MODULA2_COMMENT' | 
	 *         value='MODULA3_COMMENT' | 
	 *         value='MODULA2_CHARINT' | 
	 *         value='MODULA2_INTEGER' | 
	 *         value='MODULA2_LITERALDQ' | 
	 *         value='MODULA2_LITERALSQ' | 
	 *         value='PASCAL_COMMENT' | 
	 *         value='PASCAL_IDENTIFIER' | 
	 *         value='PASCAL_INTEGER' | 
	 *         value='PASCAL_REAL' | 
	 *         value='PASCAL_STRING' | 
	 *         value='SPACES' | 
	 *         value='TAB' | 
	 *         value='NEW_LINE' | 
	 *         value=REGEX
	 *     )
	 */
	protected void sequence_CannedExpression_Pattern_RegularExpression(EObject context, Pattern semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     specifications+=Specification*
	 */
	protected void sequence_File(EObject context, File semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     value=REGEX
	 */
	protected void sequence_RegularExpression(EObject context, Pattern semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, GlaPackage.Literals.PATTERN__VALUE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, GlaPackage.Literals.PATTERN__VALUE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getRegularExpressionAccess().getValueREGEXTerminalRuleCall_0(), semanticObject.getValue());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (pattern=Pattern auxiliaryScannerName=AuxiliaryScannerName? tokenProcessorName=TokenProcessorName?)
	 */
	protected void sequence_Specification(EObject context, Specification semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=IDENTIFIER pattern=Pattern auxiliaryScannerName=AuxiliaryScannerName? tokenProcessorName=TokenProcessorName?)
	 */
	protected void sequence_Specification_TokenName(EObject context, TokenName semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     name=IDENTIFIER
	 */
	protected void sequence_TokenName(EObject context, TokenName semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         value='c_mkchar' | 
	 *         value='c_mkint' | 
	 *         value='c_mkstr' | 
	 *         value='EndOfText' | 
	 *         value='lexerr' | 
	 *         value='mkidn' | 
	 *         value='mkint' | 
	 *         value='mkstr' | 
	 *         value='modula_mkint'
	 *     )
	 */
	protected void sequence_TokenProcessorName(EObject context, TokenProcessorName semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
